<template>
  <CardVue height="2.8rem" title="活动宣传" style="">
    <div class="layout">
      <div class="layout-header">
        <div class="layout-header-item">
          <div class="layout-header-item-title">活动上传</div>
          <div class="layout-header-item-num">
            {{ publicizeData.activeCount || 0 }}
          </div>
        </div>
        <div class="layout-header-item">
          <div class="layout-header-item-title">宣传报道</div>
          <div class="layout-header-item-num">
            {{ publicizeData.publicizeCount || 0 }}
          </div>
        </div>
        <div class="layout-header-item">
          <div class="layout-header-item-title">荣誉表彰</div>
          <div class="layout-header-item-num">
            {{ publicizeData.recognitionCount || 0 }}
          </div>
        </div>
      </div>
      <div class="table">
        <div class="row th">
          <div class="col">排名</div>
          <div class="col">社会组织名称</div>
          <div class="col">活动数量</div>
        </div>
        <div class="body">
          <div class="row" v-for="(it, index) in dzData1">
            <div class="col">top{{ index + 1 }}</div>
            <div class="col">
              {{ it.name || '' }}
            </div>
            <div class="col">{{ it.value ?? '/' }}</div>
          </div>
        </div>
      </div>
    </div>
  </CardVue>
</template>
<script setup lang="ts">
import CardVue from '@/views/largeScreen/components/card/card.vue'
import { onMounted, ref } from 'vue'
import { actSort, publicize } from '@/api/spotCheck/spotCheck'
interface PublicizeData {
  activeCount: string
  publicizeCount: string
  recognitionCount: string
}

const publicizeData = ref<PublicizeData>({
  activeCount: '',
  publicizeCount: '',
  recognitionCount: ''
})

const dzData1 = ref([])

onMounted(() => {
  //活动宣传
  publicize().then((res) => {
    publicizeData.value = res.data
  })

  actSort().then((res) => {
    dzData1.value = res.data
      .map((i) => ({
        name: i.orgName,
        value: i.ac
      }))
      .slice(0, 5)
  })
})
</script>

<style scoped lang="scss">
.layout {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding-top: 0.1rem;
  .layout-header {
    width: 100%;
    height: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .layout-header-item {
      //width: 1rem;
      padding: 0 0.1rem;
      border: 1px solid #068e9b;
      box-sizing: border-box;
      .layout-header-item-title {
        font-size: 0.2rem;
        color: #068e9b;
        text-align: center;
      }
      .layout-header-item-num {
        font-size: 0.2rem;
        color: #fff;
        text-align: center;
      }
    }
  }
  .table {
    width: 100%;
    height: calc(100% - 0.5rem);
    box-sizing: border-box;
    padding: 0.1rem 0;

    .body {
      overflow-y: scroll;
      height: calc(100% - 0.3rem);
    }
    .row {
      width: 100%;
      display: flex;
      margin-bottom: 0.09rem;
      height: 0.3rem;
      .col {
        color: #04f5d3;
        font-size: 0.2rem;
      }
      .col:nth-child(1) {
        width: 0.8rem;
        text-align: center;
      }
      .col:nth-child(2) {
        flex: 1;
        min-width: 0;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .col:nth-child(3) {
        width: 1rem;
        text-align: center;
      }
    }
    .body::-webkit-scrollbar {
      display: none; /* 隐藏滚动条 */
    }
    .row:last-child {
      margin-bottom: 0;
    }
    .th {
      .col {
        color: #04f5d3;
        font-size: 0.22rem;
        font-weight: 700;
      }
    }
  }
}
</style>
